aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/[username]/invoice
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-08 16:46:10 -0800
committerAdam Soltys <[email protected]>2023-02-08 16:46:10 -0800
commit9e07f7e2e8a393edb9aa7a6010e576ec35f0495f (patch)
tree9519f379d8f05f095a2098d40c20f1e274ee3445 /src/routes/(app)/[username]/invoice
parent6790cc3d28b3d412d52293771047f342530a5499 (diff)
downloadcoinos-ui-9e07f7e2e8a393edb9aa7a6010e576ec35f0495f.tar.gz
coinos-ui-9e07f7e2e8a393edb9aa7a6010e576ec35f0495f.zip
invoice requests and btc deposits
Diffstat (limited to 'src/routes/(app)/[username]/invoice')
-rw-r--r--src/routes/(app)/[username]/invoice/[hash]/+layout.server.js7
-rw-r--r--src/routes/(app)/[username]/invoice/[hash]/+page.svelte12
2 files changed, 12 insertions, 7 deletions
diff --git a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js b/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js
index 0f6168e3..b5323d3f 100644
--- a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js
+++ b/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js
@@ -2,11 +2,16 @@ import Qr from 'qrcode-base64';
import { get } from '$lib/utils';
import { redirect } from '@sveltejs/kit';
-export async function load({ depends, params, url }) {
+export async function load({ depends, params, url, parent }) {
depends('app:invoice');
+ let { user } = await parent();
let { hash } = params;
let invoice = await get(`/invoice/${hash}`);
+
+ if (user && invoice.uid !== user.id && !url.pathname.includes('tip'))
+ throw redirect(307, `/send/invoice/${hash}`);
+
let { amount, received } = invoice;
amount = parseInt(amount);
diff --git a/src/routes/(app)/[username]/invoice/[hash]/+page.svelte b/src/routes/(app)/[username]/invoice/[hash]/+page.svelte
index 6d7e1dda..ad9721e7 100644
--- a/src/routes/(app)/[username]/invoice/[hash]/+page.svelte
+++ b/src/routes/(app)/[username]/invoice/[hash]/+page.svelte
@@ -13,8 +13,8 @@
$: refresh(data);
let { invoice, id, user, sm, lg } = data;
let {
- address,
amount,
+ hash,
type,
rate,
received,
@@ -34,8 +34,8 @@
let refresh = (data) => {
({ invoice, id } = data);
({
- address,
amount,
+ hash,
type,
rate,
received,
@@ -61,8 +61,8 @@
});
});
- $: link = address ? text : `lightning:${text}`;
- $: txt = address || text;
+ $: link = type === 'bitcoin' ? text : `lightning:${text}`;
+ $: txt = type === 'bitcoin' ? hash : text;
let full;
let toggle = () => {
@@ -115,8 +115,8 @@
{/if}
<div class="w-full flex justify-center">
- <button class="flex rounded-full border py-2 px-5 hover:opacity-80" on:click={() => copy(txt)}
- ><Icon icon="copy" style="mr-1" />
+ <button class="flex rounded-full border py-2 px-5 hover:opacity-80" on:click={() => copy(txt)}>
+ <Icon icon="copy" style="mr-1" />
<div class="text-secondary">{txt.substr(0, 10)}..{txt.substr(-6)}</div></button
>
</div>